package com.icloud.common.database.enums;

import lombok.Getter;

@Getter
public enum ArticleTypeEnum {
    ALL("ALL"),
    ORIGINAL("ORIGINAL"),
    VIDEO("VIDEO"),
    IMG("IMG"),
    WORD("WORD");

    private final String code;

    ArticleTypeEnum(String code){
        this.code = code;
    }

    public static ArticleTypeEnum byCode(String code) {
        for (ArticleTypeEnum e: ArticleTypeEnum.values()) {
            if (e.code.equalsIgnoreCase(code)) {
                return e;
            }
        }
        return null;
    }
    public static boolean isOriginal(String code){
        return ORIGINAL.getCode().equalsIgnoreCase(code);
    }
    public static boolean isVideo(String code){
        return VIDEO.getCode().equalsIgnoreCase(code);
    }
    public static boolean isImg(String code){
        return IMG.getCode().equalsIgnoreCase(code);
    }
    public static boolean isWord(String code){
        return WORD.getCode().equalsIgnoreCase(code);
    }
    public static boolean isAll(String code){
        return ALL.getCode().equalsIgnoreCase(code);
    }
}
